<template>
	<view class="columnbox content">
		<view class="info-title">邀请患者</view>
		<view class="columnbox ewm-box">
			<view>微信扫一扫，关注我去问诊</view>
			<image class="ewm-img" :src="user.erweima" mode="widthFix"></image>
		</view>
		<view class="rowbox send-btn" @click="showImg">
			分享公众号二维码
			<!-- <button class="share-btn" open-type="share">分享公众号二维码</button> -->
		</view>
	</view>
</template>

<script>
	export default {
		computed: {
			user() {
				return this.$store.state.user
			},
			isLogin() {
				return this.$store.state.isLogin
			},
		},
		data() {
			return {
				ewmurl: '',
				id: '',
				memberid: '',
				connectcount: 0
			};
		},
		onLoad(options) {
			// this.ewmurl = options.url
			// this.id = options.data * 1
		},
		onShow() {
			console.log(this.user)
			// if (this.memberid != '') {
			// 	this.sendMessage(this.id + '', 6)
			// }
		},
		methods: {
			showImg() {
				wx.downloadFile({
					url: this.user.erweima,
					success: (res) => {
						wx.showShareImageMenu({
							path: res.tempFilePath
						})
					}
				})
			},
			// sendMessage(content, classify) {
			// 	getApp().globalData.chatSocket.send({
			// 		data: JSON.stringify({
			// 			"receiveid": this.memberid,
			// 			"content": content,
			// 			"classify": classify,
			// 			// "nickname": this.user.name,
			// 			// "logo": this.user.logo
			// 		}),
			// 		success: res => {
			// 			console.log('发送成功', res)
			// 			uni.showToast({
			// 				title: '发送成功'
			// 			})
			// 			this.memberid = ''
			// 		},
			// 		fail: (err) => {
			// 			console.log('发送失败', err)
			// 			this.reConnect(content, classify)
			// 		}
			// 	});
			// },
			reConnect(content, classify) {
				setTimeout(() => {
					if (this.connectcount < 10) {
						this.connectcount++
						this.sendMessage(content, classify)
					} else {
						this.connectcount = 0
						uni.showToast({
							title: '发送消息失败',
							icon: 'none'
						})
					}
				}, 500)
			},
			sendUser() {
				uni.navigateTo({
					url: '/packageA/yaofang/choosePatient?from=goods'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		font-family: PingFang SC;
		height: 100vh;
		background: linear-gradient(to bottom, #1a5cde, #b6c8f4);
		justify-content: flex-start;
	}

	.info-title {
		margin-top: 100rpx;
		color: #fff;
		font-size: 40rpx;
	}

	.ewm-box {
		background: #fff;
		border-radius: 20rpx;
		width: 600rpx;
		padding: 40rpx 0;
		font-size: 28rpx;
		color: #929495;
		line-height: 40rpx;
		margin-top: 40rpx;

		.ewm-img {
			width: 500rpx;
			height: 500rpx;
			margin-top: 20rpx;
		}
	}

	.send-btn {
		width: 600rpx;
		background: #1e76ff;
		height: 90rpx;
		position: fixed;
		bottom: 70rpx;

		.share-btn {
			position: absolute;
			width: 100%;
			height: 90rpx;
			z-index: 9;
			opacity: 0;
		}
	}
</style>